package panel.help;

import com.plealog.genericapp.api.EZEnvironment;
import imgs.ImageResource;
import util.BrowserLauncherUtil;

import javax.swing.*;
import java.awt.*;

public class AboutDialog {
	/**
	 * 弹出关于对话框
	 */
	public static void showAboutDialog() {
		JButton docButton = new JButton("查看使用说明");
		// 浏览器打开
		docButton.addActionListener(e -> BrowserLauncherUtil.openUrl(EZEnvironment.getMessage("HelpUrl")));

		JButton okButton = new JButton("好的");
		okButton.addActionListener(e -> {
			Dialog d = (Dialog) SwingUtilities.getRootPane(okButton).getParent(); //拿到外部的对话框
			d.dispose();
		});

		JOptionPane.showOptionDialog(EZEnvironment.getParentFrame(), "少年，\n善用此工具，与我一起拯救苇名！",
				"弦一郎曾经说过", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE,
				new ImageIcon(ImageResource.getImage("xian.png")),
				new Object[]{docButton, okButton}, 0);
	}
}
